package com.hinnotek.warehouse.ui

import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.hinnotek.warehouse.BR
import com.hinnotek.warehouse.R
import com.hinnotek.warehouse.bean.DeviceDetailBean
import com.hinnotek.warehouse.bean.DeviceInfoBean
import com.hinnotek.warehouse.bean.ProjectTree
import com.hinnotek.warehouse.databinding.ActivityDeviceUsageDetailBinding
import com.hinnotek.warehouse.databinding.ItemDeviceUsageQueryLayoutBinding
import com.lee.common.adapter.binding.SimpleBindingAdapter
import com.lee.common.base.BaseActivity
import com.lee.common.ext.init
import com.lee.common.utils.ACTIVITY_DEVICE_USAGE_DETAILS
import dagger.hilt.android.AndroidEntryPoint

/**
 * 设备使用情况详情页面
 */
@Route(path = ACTIVITY_DEVICE_USAGE_DETAILS)
@AndroidEntryPoint
class DeviceUsageDetailActivity : BaseActivity<ActivityDeviceUsageDetailBinding>() {

    private lateinit var adapter: SimpleBindingAdapter<DeviceDetailBean, ItemDeviceUsageQueryLayoutBinding>

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_device_usage_detail)
        setTitle("基本信息")
    }

    override fun initVew() {
        adapter =
            SimpleBindingAdapter(R.layout.item_warehousing_layout, ArrayList(), BR.contentData)
        bindingView.recyclerView.init()
        bindingView.recyclerView.adapter = adapter
        val data2 = intent.getSerializableExtra("DeviceDetail") as DeviceInfoBean
        val details = mutableListOf<DeviceDetailBean>().apply {
            this.add(DeviceDetailBean("设备名称", data2.deviceName))
            this.add(DeviceDetailBean("材料编号", data2.materielNum ?: "无"))
            this.add(DeviceDetailBean("设备型号", data2.deviceModel))
            this.add(DeviceDetailBean("产品序列号", data2.productNum))
            this.add(DeviceDetailBean("供应商", data2.personName))
            if (data2.installTime != null)
                this.add(DeviceDetailBean("安装时间", data2.installTime))
            this.add(DeviceDetailBean("是否更换", data2.replaceFlagData))
            if (data2.replaceTime != null)
                this.add(DeviceDetailBean("更换时间", data2.replaceTime))
            this.add(DeviceDetailBean("是否维保期", data2.maintenanceData))
        }
        adapter.setNewInstance(details)
    }

    override fun setData() {

    }

}